using System.Threading.Tasks;
using JlPay.Sdk.Core;
using JlPay.Sdk.Models.Trans.B2c;

namespace JlPay.Sdk.Services.Trans.B2c
{
    /// <summary>
    /// 微支付服务
    /// </summary>
    public class MicroPayService : BaseService
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="config">配置对象</param>
        public MicroPayService(Config config) : base(config)
        {
        }

        /// <summary>
        /// 微支付
        /// </summary>
        /// <param name="request">微支付请求</param>
        /// <returns>微支付响应结果</returns>
        public async Task<MicroPayResponse> MicroPayAsync(MicroPayRequest request)
        {
            return await PostAsync<MicroPayRequest, MicroPayResponse>(request, MicroPayRequest.API_URL);
        }

        /// <summary>
        /// 微支付预授权
        /// </summary>
        /// <param name="request">微支付预授权请求</param>
        /// <returns>微支付预授权响应结果</returns>
        public async Task<MicroPayPreAuthResponse> MicroPayPreAuthAsync(MicroPayPreAuthRequest request)
        {
            return await PostAsync<MicroPayPreAuthRequest, MicroPayPreAuthResponse>(request, MicroPayPreAuthRequest.API_URL);
        }
    }
} 